from django.utils.deprecation import MiddlewareMixin
from django.http.response import JsonResponse


# 中间件需要到settings加载自定义中间件才生效   文件夹名.文件名.类名
class MyMiddleware(MiddlewareMixin):
    def process_request(self, request):
        white_list = ["/register/", "/login/", "/myimg/"]
        print(request.path)
        if request.path not in white_list:
            if request.GET.get("token"):
                print(request.GET.get("token"))
            return JsonResponse({"msg": "请先登录再访问"})